import {clearCookie, getCookie, setCookie} from '@/utils/cookie';

import storages from '@/localStorages'

const {TOKEN_KEY, TOKEN_EXPIRE} = storages

/**
 * 设置token
 * @param {[type]} value [键值]
 */
const setToken = (value: any) => {
  setCookie(TOKEN_KEY, value, TOKEN_EXPIRE)
  // localStorage.setItem(TOKEN_KEY, value)
}
/**
 * 重置token有效时间
 */
const refreshToken = () => {
  setToken(getToken())
}

const getToken = () => {
  return getCookie(TOKEN_KEY)
}

const clearToken = () => {
  return clearCookie(TOKEN_KEY)
}

export {
  TOKEN_KEY, setToken, getToken, clearToken, refreshToken
}
